Skip to content

Provide node labels for webhook template #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 10, 2021

Conversation

imuqtadir
Copy link
Contributor

Issue #, if available: #265

Description of changes: The node labels would be provided for users to use however by default we will not be sending out node labels. The users can now provide their webhook template and display the all/desired labels.

Sample:

// Display all node labels in raw format
Webhook Template: `{"text":"[NTH][Instance Interruption] EventID: {{ .EventID }} - Kind: {{ .Kind }} - NodeLabels: {{ .NodeLabels }} - Description: {{ .Description }} - Start Time: {{ .StartTime }}"}`

Webhook Content:
{"Content":"[NTH][Instance Interruption] EventID:  XXXX  - Kind: SCHEDULED_EVENT - NodeLabels: map[stage:prod beta.kubernetes.io/arch:amd64 beta.kubernetes.io/os:linux kubernetes.io/arch:amd64 kubernetes.io/hostname:ip-XXX-XXX-0-1.ec2.internal kubernetes.io/os:linux foo:bar] - Description: XXXX - Start Time: 2021-03-04 22:50:34 +0000 UTC"}
// Display all node labels in formatted form (change per your preference)
Webhook Template: `{"text":"[NTH][Instance Interruption] EventID: {{ .EventID }} - Kind: {{ .Kind }} - {{ range $key, $value := .NodeLabels }}{{ $key }}:{{ $value }} {{ end }} - Description: {{ .Description }} - Start Time: {{ .StartTime }}"}`

Webhook Content:
{"Content":"[NTH][Instance Interruption]  EventID: XXXX - Kind: SCHEDULED_EVENT - stage:prod beta.kubernetes.io/arch:amd64 beta.kubernetes.io/os:linux kubernetes.io/arch:amd64 kubernetes.io/hostname:ip-XXX-XXX-0-1.ec2.internal kubernetes.io/os:linux foo:bar - Description: XXXX   - Start Time: 2021-03-04 22:50:34 +0000 UTC"}
// Display specific label eg. stage label here
Webhook Template: `{"text":"[NTH][Instance Interruption] EventID: {{ .EventID }} - Kind: {{ .Kind }} - Stage: {{ .NodeLabels.stage }} - Description: {{ .Description }} - Start Time: {{ .StartTime }}"}`

Webhook Content:
{"Content":"[NTH][Instance Interruption] EventID: XXXX - Kind: SCHEDULED_EVENT - Stage: prod - Description: XXXX  - Start Time: 2021-03-04 22:50:34 +0000 UTC"}
// If the value of label is missing, we get <no value> but wouldn't fail webhook notification
Webhook Content:
{"Content":"[NTH][Instance Interruption] EventID: XXXX - Kind: SCHEDULED_EVENT - Stage: <no value> - Description: XXXX - Start Time: 2021-03-04 22:50:34 +0000 UTC"}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@imuqtadir imuqtadir requested a review from bwagner5 March 5, 2021 16:17
@imuqtadir imuqtadir linked an issue Mar 5, 2021 that may be closed by this pull request
Copy link
Contributor

@bwagner5 bwagner5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be good once NodeLabels is moved to interruptionEvent struct.

@imuqtadir imuqtadir requested a review from bwagner5 March 9, 2021 16:50
Copy link
Contributor

@bwagner5 bwagner5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made one little comment. But other than that it looks good!

Copy link
Contributor

@bwagner5 bwagner5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! nicely done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to send node label to webhook?
2 participants